using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace NhaThuocOnline.Entities.Mapping
{
    public class HoaDonBanHangMap : EntityTypeConfiguration<HoaDonBanHang>
    {
        public HoaDonBanHangMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.SoHoaDon)
                .HasMaxLength(20);

            this.Property(t => t.TongTienHoaDon)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("HoaDonBanHang");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.SoHoaDon).HasColumnName("SoHoaDon");
            this.Property(t => t.NgayLapHoaDon).HasColumnName("NgayLapHoaDon");
            this.Property(t => t.TongTienHoaDon).HasColumnName("TongTienHoaDon");
            this.Property(t => t.KhachHangId).HasColumnName("KhachHangId");
            this.Property(t => t.ICDId).HasColumnName("ICDId");
            this.Property(t => t.BenhNhanId).HasColumnName("BenhNhanId");
            this.Property(t => t.BacSiId).HasColumnName("BacSiId");
            this.Property(t => t.NhathuocId).HasColumnName("NhathuocId");

            // Relationships
            this.HasOptional(t => t.BacSi)
                .WithMany(t => t.HoaDonBanHangs)
                .HasForeignKey(d => d.BacSiId);
            this.HasOptional(t => t.BenhNhan)
                .WithMany(t => t.HoaDonBanHangs)
                .HasForeignKey(d => d.BenhNhanId);
            this.HasOptional(t => t.NhaThuoc)
                .WithMany(t => t.HoaDonBanHangs)
                .HasForeignKey(d => d.NhathuocId);

        }
    }
}
